package com.net.xpay.common.manager.impl.partner;

import com.google.common.base.Preconditions;
import com.net.common.annotation.ReadTransactional;
import com.net.common.dao.BasicMapper;
import com.net.common.manager.AbstractVersionedManager;
import com.net.xpay.common.dao.partner.PartnerAccountMapper;
import com.net.xpay.common.domain.partner.PartnerAccount;
import com.net.xpay.common.manager.partner.PartnerAccountManager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;


@Component
@ReadTransactional
public class PartnerAccountManagerImpl extends AbstractVersionedManager<PartnerAccount> implements PartnerAccountManager{

    @Autowired
    private PartnerAccountMapper mapper;


    @Override
    protected BasicMapper<Long, PartnerAccount> getMapper() {
        return mapper;
    }

    @Override
    public PartnerAccount getByIdWithLock(Long id) {
        Preconditions.checkArgument(id != null);
        return mapper.getByIdWithLock(id);
    }

    /**
     * 搜索账户有余额的
     */
    @Override
    public List<PartnerAccount> listHasLeftMoneyAccount() {
        return nonEmptyList(mapper.listHasLeftMoneyAccount());
    }
}
